Skip to content

merge py2 and py3 argparse#352

Merged
matthiaskramm merged 1 commit into
python:masterfrom
tharvik:improve_argparse
Jul 11, 2016
Merged

merge py2 and py3 argparse#352
matthiaskramm merged 1 commit into
python:masterfrom
tharvik:improve_argparse

Conversation

@tharvik

@tharvik tharvik commented Jul 11, 2016

Copy link
Copy Markdown
Contributor

Add types to argparse, merge both version. There is some undocumented (in general, argparse is badly documented on docs.python.org) element which I removed (thus being more implementation agnostic), but I keep some used by mypy, let me know if something break.

for example help(argparse.HelpFormatter)

Only the name of this class is considered a public API. All the methods provided by the class are considered an implementation detail.

but mypy use the __init__ of it.

Comment thread stdlib/2and3/argparse.pyi
conflict_handler: str = ...,
add_help: bool = ...) -> None: ...
def add_argument(self,
*name_or_flags: Union[str, List[str]],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stray asterisk?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From docs.python.org, we can have parser.add_argument('-f', '--foo'), so that seems correct to me.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant: You can only have one "varargs" argument in a function definition. Maybe you need to remove the single "" below?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ho, I see what you mean, correct, that's a typo (fixed).

@tharvik tharvik force-pushed the improve_argparse branch from 81da6f4 to 87235ad Compare July 11, 2016 13:24
@matthiaskramm matthiaskramm merged commit b48ddf7 into python:master Jul 11, 2016
@tharvik tharvik deleted the improve_argparse branch July 11, 2016 13:39
hswong3i pushed a commit to alvistack/python-typeshed that referenced this pull request May 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants